var Kuo_UP_Tencent = {
    SecretId:"",
    SecretKey:"",
    SecretHost:"",
    Bucket:"",
    Config:(config)=>{
        if(config ){
            if(config.SecretKey){
                Kuo_UP_Tencent.SecretId = config.SecretId;
            }
            if( config.SecretKey){
                Kuo_UP_Tencent.SecretKey = config.SecretKey;
            }
            if(config.SecretHost){
                Kuo_UP_Tencent.SecretHost = config.SecretHost;
            }
            if(config.Bucket){
                Kuo_UP_Tencent.Bucket = config.Bucket;
            }
        }

        return Kuo_UP_Tencent;

    },OSSUpload:async (file,file_)=>{

    },Upload:async (file,file_)=>{
        var neirong = FS.readFileSync(file);
        var $start = Mode("Tools").Time();
        var $end = Mode("Tools").Time()+300;
        var $KeyTime = $start + ";" + $end;
        var $Authorization = [
            "q-sign-algorithm=sha1",
            "q-ak="+Kuo_UP_Tencent.SecretId,
            "q-sign-time=" + $KeyTime,
            "&q-key-time=" + $KeyTime,
            "q-header-list=host",
            "q-url-param-list="
        ];
        var $SignKey =  CRYPTO.createHmac('sha1', Kuo_UP_Tencent.SecretKey ).update( $KeyTime).digest('hex');
        var $HttpString = "put\n" + file_ +"\n\nhost="+Kuo_UP_Tencent.SecretHost+"\n";
        var  $jjj = "sha1\n" + $KeyTime + "\n" + CRYPTO.createHash('sha1').update($HttpString).digest('hex') +"\n";
        $Authorization.push("q-signature=" +CRYPTO.createHmac('sha1', $SignKey ).update( $jjj ).digest('hex'));
        var SHUJU = {
            body:neirong,
            method:"PUT"
        };
        SHUJU.headers = {
            'Content-Type': 'application/octet-stream',
            'Authorization':$Authorization.join('&'),
            'Date' :   Mode("Tools").UTC(),
            'Host' :  Kuo_UP_Tencent.SecretHost,
            'Content-Length':  Buffer.byteLength(neirong)
        };
        var fan = await POST("https://"+Kuo_UP_Tencent.SecretHost+file_,null,SHUJU);
        if(fan !== false && fan == ""){
            return  true;
        }
        return  false;
    }
}
module.exports = Kuo_UP_Tencent;